import Vue from 'vue'
import VueRouter from 'vue-router'
import loginRoute from './modules/login/loginRoute.js'
import homeRoute from './modules/home/homeRoute.js'
import usersRoute from './modules/users/usersRoute'
import adminRoute from './modules/admin/adminRoute.js'
import bbsRoute from './modules/bbs/bbsRoute'
Vue.use(VueRouter)
export const routes = [{
		path: '/',
		redirect: '/index',
	},
	loginRoute,
	homeRoute,
	usersRoute,
	bbsRoute,
]
export const asyncRoute = [adminRoute]
export const router = new VueRouter({
	// mode: 'history',
	// base: process.env.VUE_APP_BASEURL,
	routes,
	linkActiveClass: 'active',
	scrollBehavior(to, from, savedPosition) {
		// 期望滚动到哪个的位置
		return { x: 0, y: 0 }
	},
})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
	return VueRouterPush.call(this, to).catch((err) => err)
}